<template>
	<view class="dawn-search-warp">
		<image class="search-logo" mode="aspectFill" :src="appConfig.logoUrl"></image>
		<view class="dawn-search-box dawn-color-grey" @click="navLink()">
			<view class="tn-icon-search"></view>
			<view class="tn-padding-left-xs dawn-text-sm">搜索更多好课</view>
		</view>
		<tn-button style="height: 30px;" backgroundColor="tn-main-gradient-orange" shape="shape"
			padding="20rpx 15rpx" shadow>
			<text class="tn-icon-bookmark-fill tn-padding-right-ss"></text>
			<text class="tn-text-ellipsis">签到</text>
		</tn-button>
	</view>
</template>

<script>
	import page_mixin from '@/mixins/page_mixin.js'
	import {
		mapGetters
	} from "vuex";
	const app = getApp();
	export default {
		name: 'dawnBar',
		computed: mapGetters(['appConfig', 'uid', 'isLogin', 'userInfo']),
		props: {
			// 标题
			title: {
				type: String,
				default: ''
			},
			// 左边图标
			iconLeft: {
				type: String,
				default: 'left-fill'
			},
			iconHome: {
				type: String,
				default: 'home-love-fill'
			},
			// 是否显示图标
			iconHomeShow: {
				type: Boolean,
				default: false
			},
			// 右边图标
			iconRightItems: {
				type: Array,
				default () {
					return []
				}
			},
			// 是否显示图标
			iconShow: {
				type: Boolean,
				default: true
			},
			searchShow: {
				type: Boolean,
				default: false
			},
			searchText: {
				type: String,
				default: "请点击搜索"
			},
		},
		mounted() {

		},
		methods: {
			search() {
				this.$emit('search');
			},
			// 跳转回首页
			navLink() {
				uni.navigateTo({
					url: '/pagesSub/education/search'
				})
			},
			// 点击左上角返回按钮时触发事件
			toBack() {
				console.log("goBack");
				// 通过判断当前页面的页面栈信息，是否有上一页进行返回，如果没有则跳转到首页
				const pages = getCurrentPages()
				if (pages && pages.length > 0) {
					const firstPage = pages[0]
					if (pages.length == 1 && (!firstPage.route || firstPage.route != 'main/index/index?init=no')) {
						uni.switchTab({
							url: '/pages/index/index?init=no'
						})
					} else {
						uni.navigateBack({
							delta: 1
						})
					}
				} else {
					uni.switchTab({
						url: '/pages/index/index?init=no'
					})
				}
			},
			// 跳转回首页
			navIndex() {
				uni.switchTab({
					url: '/pages/index/index?init=no'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dawn-search-warp{
		display: flex;
		align-items: center;
		padding: 10px;
		border-radius: $dawn-btn-radius;
		box-shadow: $dawn-box-shadow;
	}
	
	::v-deep .tn-custom-nav-bar {
		background-color: $dawn-theme-color !important;
	}
	
	::v-deep .tn-custom-nav-bar__bar {
		// background-color: #3571BB !important;
		background-color: $dawn-theme-color !important;
	}
</style>